-- 示例1：调用Java静态方法
local reversed = StaticUtils:reverseString("hello")
-- local reversed = StaticUtils.reverseString("hello world")
print("[Lua] 反转字符串结果:", reversed)

-- 示例2：创建Lua Table
userTable = {
    name = "Alice",
    age = 30,
    greet = function(self)
        return "你好，" .. self.name
    end
}

-- 示例3：实现Java接口
luaProcessor = {
    process = function(input)
        return string.upper(input).." (processed by Lua)"
    end
}

-- 示例4：协程生成器
function numberGenerator()
    local i = 0
    return function()
        i = i + 1
        return i
    end
end
genFunc = numberGenerator()
numberCoroutine = coroutine.create(genFunc)

-- 示例5：访问Java数组，lua的索引从1开始
print("\n[Lua] 遍历Java数组:")
for i=1, #ArrayHolder.numbers do
    print("[Lua] 数组元素", i, ":", ArrayHolder.numbers[i])
end

-- 示例7：使用Java集合
local list = ArrayList.new()
list:add("第一个元素")
list:add("第二个元素")
print("\n[Lua] 集合大小:", list:size())

-- 示例8：创建闭包
function createCounter()
    local count = 0
    return function()
        count = count + 1
        return count
    end
end

-- 示例9：异常处理
local ok, err = pcall(FileUtils.riskyOperation)
if not ok then
    print("\n[Lua] 捕获到Java异常:", err)
end

-- 示例10：回调监听器
luaListener = {
    onEvent = function(msg)
        print("\n[Lua] 收到回调消息:", msg)
        return "这是来自Lua的响应"
    end
}
